草庐IT

java - Morphia 在 Spring 通过 log4j 登录

全部标签

ruby - 无法通过 rvm 安装 compass

在Ubuntu11.10中,我是一个快乐且无忧的compass用户。我升级到12.04并遇到了这个问题:Compass(ruby)encodingerror我以某种方式设法解决了通过rvm在我的一台计算机上安装ruby​​的问题,但现在我在另一台计算机上遇到了不同的错误(具有相同的初始问题)。我安装了ruby​​和compass并默认使用全局gemset:gemlist***LOCALGEMS***bundler(1.1.3)chunky_png(1.2.5)compass(0.12.1)fssm(0.2.9)rake(0.9.2.2)rubygems-bundler(1.0.0)rv

ruby - 当通过 Rake 测试运行时,Minitest #setup 和 #teardown 不会被调用

我有一个MiniTest套件。我使用的是基本的Minitest::Unit::TestCase,而不是规范。我在我的TestCase子类中定义了setup和teardown方法。当我像这样运行测试文件时,它们可以完美运行:rubytest/whatever_test.rb。但是当我运行raketest时,setup和teardown没有被调用。我的Rakefile的相关部分是:require'rake/testtask'Rake::TestTask.newdo|t|t.test_files=FileList['test/*_test.rb']t.verbose=trueend为什么在使

ruby - 通过方法调用时如何将参数传递给proc?

proc=Proc.newdo|name|puts"Thankyou#{name}!"enddefthankyieldendproc.call#outputnothing,justfineproc.call('God')#=>ThankyouGod!thank&proc#outputnothing,too.Fine;thank&proc('God')#Error!thank&proc.call('God')#Error!thankproc.call('God')#Error!#So,whatshouldIdoifIhavetopassthe'God'totheprocandusethe

ruby - 设计 - 使用 Ajax 登录

是否有可能为ajax通信修改设计SessionsController?编辑我找到了解决方案,并将其发布到答案中,谢谢 最佳答案 1。生成DeviseController以便我们修改它railsgdevise:controllers现在我们在app/controllers/[model]目录中拥有所有Controller2。编辑routes.rb让我们将Devise设置为使用我们修改后的SessionsController首先将此代码(当然将:users更改为您的设计模型)添加到config/routes.rbdevise_for:u

ruby-on-rails - Ruby on Rails 在保存之前通过关联对象 has_many

在RubyonRails项目中,我试图在将所有内容保存到数据库之前访问ActiveRecord上的关联对象。classPurchase如果我像这样构建我的对象:purchase=Purchase.new(item_ids:[1,2,3])并尝试保存它item_validation方法还没有填充项目集合,所以即使虽然项目已经设置,但它没有机会调用任何项目的check_something方法。是否可以在我的购买模型和关联模型保留之前访问项目集合,以便我可以对它们运行验证?如果我将item_validation方法更改为:defitem_validationpurchase_items.ea

ruby-on-rails - 通过关联获取 has_many 的 ActiveRecord::RecordInvalid 错误;连接表上的验证问题

我有如下三个关联模型:classProduct当我做类似的事情时:doc=user.documents.builddoc.update_attributes(:product_ids=>[1,2])并且description验证失败,然后我得到false和doc上的相应错误。这正是我想要的。但是,如果doc已经存在,例如:doc=user.documents.firstdoc.update_attributes(:product_ids=>[1,2])并且description验证失败,然后我得到一个ActiveRecord::RecordInvalid错误。我很清楚为什么会这样——i

ruby - 在 JRuby 中,如何确定导致 java.lang.ThreadDeath 的原因?

在为一些与JRuby中的临时文件交互的代码运行单元测试时,我有时会得到以下信息:Exception:java.lang.ThreadDeaththrownfromtheUncaughtExceptionHandlerinthread"Thread-6395"它似乎没有引起任何问题,但这是怎么回事,我如何确定它发生在哪里?我尝试打开-d,但这并没有给我异常的堆栈跟踪。 最佳答案 FWIW:这可能与http://jira.codehaus.org/browse/JRUBY-7074有关.我偶尔会在不使用反引号但调用系统的JRuby程序中

ruby-on-rails - 处理身份登录的 OmniAuth::Error (invalid_credentials)

我使用OmniAuthIdentity进行正常登录。Rails3.2.3和Ruby1.9.3p194。目前,当现有用户尝试使用无效凭据登录时,我会收到以下错误:StartedPOST"/auth/identity/callback"for127.0.0.1at2012-07-1217:00:03-0400(identity)Callbackphaseinitiated.IdentityLoad(0.1ms)SELECT"identities".*FROM"identities"WHERE"identities"."email"='test'LIMIT1(identity)Authent

ruby-on-rails - 使用 ruby​​ mechanize 在浏览器中存储登录 session cookie

我正在尝试登录网站并通过Rails操作重定向到安全页面。我的代码看起来像这样。defredirect_to_externalagent=Mechanize.newpage=agent.get('http://example.com/home.asp')login_form=page.form_with(:name=>"loginForm")login_form.login='username'login_form.password='password'agent.submit(login_form)#cookies=agent.cookie_jar.store.map{|i|i}#ne

ruby-on-rails - 通过 Regex、Ruby 拆分时保留模式字符

我有以下字符串str="HelloWorldHowareYouIAmFine"我要把这个字符串放到下面的数组中["Hello","WorldHoware","YouIAm","Fine"]我一直在使用以下正则表达式,它正确拆分但也省略了匹配模式,我也想保留该模式。我得到的是str.split(/[a-z][A-Z]/)=>["Hell","orldHowar","ouIA","ine"]它省略了匹配模式。谁能帮我解决如何在结果数组中保留这些字符 最佳答案 在Ruby1.9中,您可以使用positivelookaheadandposi